package com.github.littleantfly.dictionarydemo;

import com.github.littleantfly.dictionary.cache.DictCache;
import com.github.littleantfly.dictionary.cache.DictCacheData;
import com.github.littleantfly.dictionary.cache.loader.AbstractDictCacheLoader;
import com.github.littleantfly.dictionary.module.DictModel;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * 初始化加载缓存所有数据示例
 * 默认缓存key使用“-”
 *
 * @author xiezhenglong
 */
//@Component
public class CacheDataInitDemo extends AbstractDictCacheLoader {

    protected CacheDataInitDemo(DictCache dictCache) {
        super(dictCache);
    }

    @Override
    protected List<DictCacheData> doGetDataList() {

        DictCacheData cacheData = new DictCacheData();
        cacheData.setKey("sex-1");
        DictModel dict = new DictModel();
        dict.setId("1");
        dict.setPid("-1");
        dict.setName("男");
        dict.setData("1");
        cacheData.setData(dict);


        DictCacheData cacheData1 = new DictCacheData();
        cacheData1.setKey("sex-2");
        DictModel dict1 = new DictModel();
        dict1.setId("2");
        dict1.setPid("-1");
        dict1.setName("女");
        dict1.setData("2");
        cacheData1.setData(dict1);


        List<DictCacheData> list = new ArrayList<>();
        list.add(cacheData);
        list.add(cacheData1);

        return list;
    }
}
